<?php
class daka_paperAction extends backendAction{
    public function _initialize() {
        parent::_initialize();
        $this->_mod = D('daka_paper');
    }
	public function _before_index() {
        
    }
    //列表页
    public function index() {
        $sort = $this->_request("sort", 'trim', 'ordid');
        $order = $this->_request("order", 'trim', 'ASC');
        $mod_pk = $this->_mod->getPk();
        
        $class_id=$this->_get('class_id','intval',0);
        $map=array();
        if($class_id){
			$map['class_id']=$class_id;
		}
		
        
		//如果需要分页
		$pagesize =C('zyb_paper_pagesize')?C('zyb_paper_pagesize'):20;
		$count = $this->_mod->where($map)->count($mod_pk);
		$pager = new Page($count, $pagesize);
		$list = $this->_mod->where($map)->order('class_id asc,'.$sort . ' ' . $order)->relation(true)->limit($pager->firstRow.','.$pager->listRows)->select();
		$page = $pager->show();
		$this->assign("page", $page);
        $this->assign('list', $list);

        $this->display();
    }



    /**
     * 
     */
    public function _before_add() {
        $daka_class = M('daka_class')->where('status=1')->select();
        $this->assign('daka_class', $daka_class);
		
		$daka_user = M('daka_user')->where('status=1')->select();
        $this->assign('daka_user', $daka_user);
    }

   public function _before_edit() {
	    $daka_class = M('daka_class')->where('status=1')->select();
        $this->assign('daka_class', $daka_class);
		
		$daka_user = M('daka_user')->where('status=1')->select();
        $this->assign('daka_user', $daka_user);
    }

    /**
     * 入库数据整理
     */
    protected function _before_insert($data = '') {
		
    }

    /**
     * 修改提交对数据
     */
    protected function _before_update($data = '') {
		
    }
	
	
}